package com.rms.hkpc.db.dao;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.WhereCondition;

import java.util.List;

public class CommonDaoUtil<K> {

    private Class<K> entityClass;
    private AbstractDao<K,Long> entityDao;

    public CommonDaoUtil(Class<K> entityClass, AbstractDao<K, Long> entityDao) {
        this.entityClass = entityClass;
        this.entityDao = entityDao;
    }

    public long insertOrReplace(K entity){
        return entityDao.insertOrReplace(entity);
    }

    public List<K> queryWhere(WhereCondition cond,WhereCondition... condMore){
        return entityDao.queryBuilder().where(cond,condMore).list();
    }

    public long getCount(){
        return entityDao.queryBuilder().count();
    }

}
